home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / RAMSES 2.2 / RAMSES 2.2 Extras / DMBaseExtra / DMDebugHelp.MOD < prev    next >
Encoding:
Modula Implementation  |  1996-06-21  |  21.7 KB  |  736 lines  |  [TEXT/MEDT]

  1. IMPLEMENTATION MODULE DMDebugHelp ;
  2.  
  3.   (*
  4.  
  5.         Implementation and Revisions:
  6.         ============================
  7.         
  8.         DM_V2.0  for  MacMETH_V2.6+  1-pass-compiler
  9.  
  10.         Author    Date        Description
  11.         ------    ----        -----------
  12.  
  13.         af        16/11/89    First implementation (DM 1.1,
  14.                             MacMETH 2.6+)
  15.         HA        20/12/89    DM V2.0, MacMETH V2.6+
  16.         af        12/02/91    PutMessageOnTop and PutMessageToBack
  17.                             added
  18.         af        29/01/92    PutMessageToBack is new default
  19.         dg        14/02/92    DM V2.2, MacMETH V3.2
  20.         af        01/04/92    Support for file writing
  21.         af        05/04/92    WriteDataStructure added to
  22.                             implement e.g. ReportOnEvent
  23.         af        23/06/93    GetModuleIdent added
  24.         af&dg    19/04/96    Now uses only DMWindIO instead of
  25.                             DMWindowIO for PC compatibility
  26.  
  27. --- END OF MODULE HISTORY ---  *)
  28.  
  29.  
  30.   FROM SYSTEM IMPORT SETREG, ADR, INLINE, ADDRESS, VAL, BYTE;
  31.   IMPORT DMQuickDraw;
  32.   IMPORT FileSystem;
  33.   IMPORT FileUtil;
  34.  
  35.   CONST
  36.   
  37.     (* event codes Inside Mac I-263 *)
  38.     nullEvent    =  0;
  39.     mouseDown    =  1;
  40.     mouseUp        =  2;
  41.     keyDown     =  3;
  42.     keyUp        =  4;
  43.     autoKey     =  5;
  44.     updateEvt    =  6;
  45.     diskEvt        =  7;
  46.     activateEvt =  8;
  47.     networkEvt    = 10;
  48.     driverEvt    = 11;
  49.     app1Evt     = 12;
  50.     app2Evt     = 13;
  51.     app3Evt     = 14;
  52.     app4Evt     = 15;
  53.     osEvt         = app4Evt;
  54.     kHighLevelEvent = 23; (* Inside Mac VI 5-21 *) (* helps to avoid import
  55.                                                       of DMSys7Events *)
  56.     
  57.     (* event masks Inside Mac I-263 *)
  58.     everyEvent            =     -1;
  59.     mDownMask               =      2;
  60.     mUpMask             =      4;
  61.     keyDownMask         =      8;
  62.     keyUpMask            =     16;
  63.     autoKeyMask            =     32;
  64.     updateMask            =     64;
  65.     diskMask            =    128;
  66.     activMask            =    256;
  67.     networkMask            =   1024;
  68.     driverMask            =   2048;
  69.     app1Mask             =   4096;
  70.     app2Mask             =   8192;
  71.     app3Mask             =  16384;
  72.     app4Mask             = -32767-1;
  73.     osEvtMask           = app4Mask;
  74.     
  75.     (* modifiers *)
  76.     btnState     = {7};     (*Bit 7 of low byte is mouse button state*)
  77.     cmdKey         = {8};    (*Bit 0 of high byte*)
  78.     shiftKey     = {9};     (*Bit 1 of high byte*)
  79.     alphaLock     = {10};    (*Bit 2 of high byte*)
  80.     optionKey     = {11};    (*Bit 3 of high byte*)
  81.     controlKey     = {12}; (*Bit 4 of high byte*)
  82.     
  83.     Monaco       = 4;
  84.     altDBoxProc = 3;
  85.     
  86.     activeFlag     =     0; (*bit 0 of modifiers for activate event*)
  87.  
  88.  
  89.   TYPE
  90.     SignedByte   = BYTE;                    (* any byte in memory           *)
  91.     Byte         = BYTE;                    (* unsigned byte for fontmgr    *)
  92.     Ptr          = POINTER TO SignedByte;   (* blind pointer                *)
  93.     Handle       = POINTER TO Ptr;          (* pointer to a master pointer  *)
  94.     ProcPtr      = Ptr;                     (* pointer to a procedure       *)
  95.     Fixed        = LONGINT;                 (* fixed point arithmetic type  *)
  96.  
  97.     Str255       = ARRAY [0..255] OF CHAR;  (* maximum string size          *)
  98.     StringPtr    = POINTER TO Str255;       (* pointer to maximum string    *)
  99.     StringHandle = POINTER TO StringPtr;    (* handle to maximum string     *)
  100.     OSType       = ARRAY [0..3] OF CHAR;
  101.     VHSelect  =  (v,h);
  102.     VHSelectR =  [v..h];
  103.     Point = RECORD
  104.               CASE :INTEGER OF
  105.                 0: v: INTEGER;
  106.                    h: INTEGER;
  107.               | 1: vh: ARRAY VHSelectR OF INTEGER;
  108.               END;
  109.             END;
  110.     EventRecord = RECORD
  111.                     what: INTEGER;
  112.                     CASE: INTEGER OF
  113.                         1: message: LONGINT;|
  114.                         2: msgchar: ARRAY [0..3] OF CHAR;|
  115.                         3: eventClass: OSType;|
  116.                         4: eventClassLongInt: LONGINT;
  117.                     END(*CASE*);
  118.                     when: LONGINT;
  119.                     CASE: INTEGER OF
  120.                         1: where: Point;|
  121.                         2: eventID: OSType; |
  122.                         3: eventIDLongInt: LONGINT;
  123.                     END(*CASE*);
  124.                     CASE: INTEGER OF
  125.                         1: modifiers: BITSET; |
  126.                         2: modifwrd: CARDINAL; (* modifier word *) |
  127.                         3: msgVal: INTEGER;
  128.                     END(*CASE*);
  129.                   END(*RECORD*);
  130.  
  131.     ControlPtr      = POINTER TO ControlRecord;
  132.     ControlHandle = POINTER TO ControlPtr;
  133.  
  134.     WindowPtr     = DMQuickDraw.GrafPtr;
  135.     WindowPeek     = POINTER TO WindowRecord;
  136.     WindowRecord =
  137.         RECORD
  138.             port:              DMQuickDraw.GrafPort;
  139.             windowKind:       INTEGER;
  140.             visible:          BOOLEAN;
  141.             hilited:          BOOLEAN;
  142.             goAwayFlag:       BOOLEAN;
  143.             spareFlag:          BOOLEAN;
  144.             strucRgn:          DMQuickDraw.RgnHandle;
  145.             contRgn:          DMQuickDraw.RgnHandle;
  146.             updateRgn:          DMQuickDraw.RgnHandle;
  147.             windowDefProc:      Handle;
  148.             dataHandle:       Handle;
  149.             titleHandle:      StringHandle;
  150.             titleWidth:       INTEGER;
  151.             ControlList:      ControlHandle;
  152.             nextWindow:       WindowPeek;
  153.             windowPic:          DMQuickDraw.PicHandle;
  154.             refCon:           LONGINT;
  155.         END;
  156.  
  157.     ControlRecord =
  158.        RECORD
  159.         nextControl:       ControlHandle;
  160.         contrlOwner:       WindowPtr;
  161.         contrlRect:        DMQuickDraw.Rect;
  162.         contrlVis:           BOOLEAN;
  163.         contrlHilite:       BOOLEAN;
  164.         contrlValue:       INTEGER;
  165.         contrlMin:           INTEGER;
  166.         contrlMax:           INTEGER;
  167.         contrlDefProc:       Handle;
  168.         contrlData:        Handle;
  169.         contrlAction:       ProcPtr;
  170.         contrlrfCon:       LONGINT;
  171.         contrlTitle:       Str255;
  172.        END; (* ControlRecord *)
  173.        
  174.   PROCEDURE ToolboxDrawString(VAR theString: Str255);     CODE 0A884H;
  175.  
  176.   PROCEDURE GetNextEvent(mask:INTEGER;
  177.                        VAR theEvent: EventRecord): BOOLEAN;     CODE 0A970H;
  178.  
  179.   VAR  toolboxString: Str255;
  180.  
  181.   PROCEDURE NewWindow (wStorage : Ptr;
  182.                        VAR boundsRect: DMQuickDraw.Rect;
  183.                       title : ARRAY OF CHAR;
  184.                       visible : BOOLEAN;
  185.                       theProc: INTEGER;
  186.                       behind: WindowPtr;
  187.                       goAwayFlag: BOOLEAN;
  188.                       refCon: LONGINT): WindowPtr;
  189.  
  190.    PROCEDURE ToolboxNewWindow(wStorage : Ptr;
  191.                               VAR boundsRect: DMQuickDraw.Rect;
  192.                               VAR title : Str255;
  193.                               visible : BOOLEAN;
  194.                               theProc: INTEGER;
  195.                               behind: WindowPtr;
  196.                               goAwayFlag: BOOLEAN;
  197.                               refCon: LONGINT): WindowPtr;       CODE 0A913H;
  198.  
  199.   BEGIN (* NewWindow *)
  200.     DMQuickDraw.ArrToStr(title,toolboxString);
  201.     RETURN ToolboxNewWindow(wStorage, boundsRect, toolboxString, visible,
  202.                            theProc, behind, goAwayFlag,  refCon);
  203.   END NewWindow;
  204.  
  205.   PROCEDURE HideWindow      (theWindow: WindowPtr);  CODE 0A916H;
  206.   PROCEDURE DisposeWindow (theWindow: WindowPtr); CODE 0A914H;
  207.  
  208.  
  209.  
  210.  
  211.   CONST lemarg = 4;
  212.   VAR charH: INTEGER; title: Str255; posInList: ADDRESS;
  213.     repFOpen: BOOLEAN; repF: FileSystem.File;
  214.   
  215.   
  216. (*.   PROCEDURE PutMessageOnTop;
  217.   BEGIN
  218.     posInList := -1D; (*first window in list*)
  219.   END PutMessageOnTop;
  220.  .*)  
  221.   PROCEDURE PutMessageToBack;
  222.   BEGIN
  223.     posInList := NIL; (*last window in list*)
  224.   END PutMessageToBack;
  225.  
  226.  
  227.  
  228.   PROCEDURE Write(ch: CHAR);
  229.   BEGIN
  230.     IF repFOpen THEN
  231.       FileSystem.WriteChar(repF,ch);
  232.     ELSE
  233.       DMQuickDraw.ToolboxDrawChar(ORD(ch));
  234.     END(*IF*);
  235.   END Write;
  236.  
  237.   PROCEDURE WriteString(s: ARRAY OF CHAR);
  238.     VAR macStr: Str255; i,n: INTEGER;
  239.   BEGIN
  240.     IF repFOpen THEN
  241.       i:= 0; n:= HIGH(s);
  242.       WHILE (i<=n) AND (s[i]<>0C) DO
  243.         FileSystem.WriteChar(repF,s[i]); INC(i)
  244.       END(*WHILE*);
  245.     ELSE
  246.       DMQuickDraw.ArrToStr(s,macStr); ToolboxDrawString(macStr);
  247.     END(*IF*);
  248.   END WriteString;
  249.  
  250.   PROCEDURE WriteLn;
  251.     CONST EOL = 15C (*ASCII CR on Mac*); VAR p: DMQuickDraw.Point;
  252.   BEGIN
  253.     IF repFOpen THEN
  254.       FileSystem.WriteChar(repF,EOL);
  255.     ELSE
  256.       DMQuickDraw.GetPen(p);
  257.       DMQuickDraw.MoveTo(lemarg,p.v+charH);
  258.     END(*IF*);
  259.   END WriteLn;
  260.  
  261.   PROCEDURE WriteInt(x: LONGINT; n: CARDINAL);
  262.     VAR x0: LONGCARD; i,d: CARDINAL;
  263.       a: ARRAY [0..14] OF CHAR;
  264.   BEGIN i := 0; x0 := ABS(x);
  265.     REPEAT
  266.       d := x0 MOD 10D;
  267.       a[i] := VAL(CHAR,d + 60B);
  268.       x0 := x0 DIV 10D; INC(i);
  269.     UNTIL x0 = 0D;
  270.     IF x < 0D THEN a[i] := "-"; INC(i) END ;
  271.     WHILE n > i DO
  272.       DEC(n); Write(" ")
  273.     END ;
  274.     REPEAT DEC(i); Write(a[i]) UNTIL i = 0
  275.   END WriteInt;
  276.  
  277.   PROCEDURE CopyString (from: ARRAY OF CHAR;   i1: INTEGER;
  278.                           VAR to: ARRAY OF CHAR; VAR i2: INTEGER);
  279.     VAR n1,n2: INTEGER;
  280.   BEGIN
  281.     n1 := HIGH(from); n2 := HIGH(to);
  282.     WHILE (i1<=n1) AND (from[i1]<>0C) AND (i2<=n2) DO
  283.       to[i2] := from[i1]; INC(i1); INC(i2);
  284.     END(*WHILE*);
  285.     IF i2<=n2 THEN to[i2] := 0C END;
  286.   END CopyString;
  287.  
  288.  
  289.   PROCEDURE IntToString(x: LONGINT; VAR str: ARRAY OF CHAR; n: CARDINAL);
  290.     VAR x0: LONGCARD; i,d: CARDINAL; j: INTEGER;
  291.       a: ARRAY [0..14] OF CHAR;
  292.       PROCEDURE Copy(ch: CHAR);
  293.       BEGIN
  294.         IF j<=HIGH(str) THEN str[j] := ch; INC(j); END; 
  295.       END Copy;
  296.   BEGIN (*IntToString*)
  297.     i := 0; x0 := ABS(x);
  298.     REPEAT
  299.       d := x0 MOD 10D;
  300.       a[i] := VAL(CHAR,d + 60B);
  301.       x0 := x0 DIV 10D; INC(i);
  302.     UNTIL x0 = 0D;
  303.     IF x < 0D THEN a[i] := "-"; INC(i) END ;
  304.     j := 0;
  305.     WHILE n > i DO
  306.       DEC(n); Copy(" ")
  307.     END ;
  308.     REPEAT DEC(i); Copy(a[i]) UNTIL i = 0;
  309.     Copy(0C);
  310.   END IntToString;
  311.  
  312.   
  313.  
  314.   PROCEDURE DocuDateAndTime;
  315.   
  316.     CONST
  317.       (* registers on 680xx CPUs *)
  318.       A0 = 8; D0 = 0;
  319.       
  320.     TYPE
  321.       Months = INTEGER;
  322.       WeekDays = INTEGER;
  323.       DateAndTimeRec =
  324.           RECORD
  325.             year: INTEGER;    (* 1904,1905,...2040 *)
  326.             month: Months;
  327.             day,              (* 1,...31 *)
  328.             hour,             (* 0,...,23 *)
  329.             minute,           (* 0,...,59 *)
  330.             second: INTEGER;  (* 0,...,59 *)
  331.             dayOfWeek: WeekDays;
  332.           END;
  333.  
  334.     VAR year,month,day,weekday, hour,minute,sec: INTEGER;
  335.  
  336.     PROCEDURE SecondsToDate (secs: LONGINT; VAR d: DateAndTimeRec);    
  337.       CONST secsToDate = 0A9C6H;
  338.     BEGIN
  339.       SETREG(D0,secs);
  340.       SETREG(A0,ADR(d));      (* error in 'Inside Macintosh' *)
  341.       INLINE(secsToDate)
  342.     END SecondsToDate;
  343.  
  344.     PROCEDURE NowInSeconds (): LONGINT;
  345.       CONST Time = 20CH;
  346.       VAR secs: POINTER TO LONGINT;
  347.     BEGIN
  348.       secs := VAL(ADDRESS,Time);
  349.       RETURN secs^
  350.     END NowInSeconds;
  351.  
  352.     PROCEDURE GetTime(VAR d: DateAndTimeRec);
  353.     BEGIN
  354.       SecondsToDate(NowInSeconds(),d)
  355.     END GetTime;
  356.  
  357.     PROCEDURE Today (VAR year, month, day, dayOfWeek: INTEGER);
  358.       VAR dt: DateAndTimeRec;
  359.     BEGIN
  360.       GetTime(dt);
  361.       year := dt.year;
  362.       month := dt.month;
  363.       day := dt.day;
  364.       dayOfWeek := dt.dayOfWeek;
  365.     END Today;
  366.     
  367.     PROCEDURE Now (VAR hour(* 0..23 *), minute, second: INTEGER);
  368.       VAR dt: DateAndTimeRec;
  369.     BEGIN
  370.       GetTime(dt);
  371.       hour := dt.hour;
  372.       minute := dt.minute;
  373.       second := dt.second;
  374.     END Now;
  375.     PROCEDURE WriteLeadZeroInt(x: INTEGER);
  376.     BEGIN
  377.       WriteInt(x DIV 10,0);
  378.       WriteInt(x MOD 10,0);
  379.     END WriteLeadZeroInt;
  380.   BEGIN
  381.     Today(year,month,day,weekday);
  382.     Now(hour,minute,sec);
  383.     WriteInt(day,0); Write("/");
  384.     WriteInt(month,0); Write("/");
  385.     WriteInt(year,0); WriteString("   ");
  386.     WriteLeadZeroInt(hour); Write("h");
  387.     WriteLeadZeroInt(minute); Write(":");
  388.     WriteLeadZeroInt(sec);
  389.   END DocuDateAndTime;
  390.  
  391.  
  392.   PROCEDURE MessageWindow (x,y,w,h: INTEGER; p: PROC);
  393.     CONST wkind = altDBoxProc;
  394.     VAR
  395.       wr: DMQuickDraw.Rect;
  396.       ptr: WindowPtr; savePort: DMQuickDraw.GrafPtr;
  397.       theEvent: EventRecord; gotAnEvent: BOOLEAN;
  398.       info: DMQuickDraw.FontInfo;
  399.   BEGIN
  400.     DMQuickDraw.GetPort(savePort);
  401.     DMQuickDraw.SetRect(wr,x,y+10+20(*menu bar*),x+w,y+10+20(*menu bar*)+h);
  402.     title:= " Debug Messages"; (*. title[0] := 16C; .*)
  403.     ptr:=NewWindow(NIL,wr,title,
  404.          TRUE,wkind,posInList,
  405.          FALSE(*no close box*),0D);
  406.     DMQuickDraw.SetPort(ptr);
  407.     DMQuickDraw.TextFont(Monaco);
  408.     DMQuickDraw.TextSize(9);
  409.     DMQuickDraw.GetFontInfo(info);
  410.     charH := info.ascent + info.descent + info.leading;
  411.     DMQuickDraw.MoveTo(lemarg,lemarg); WriteLn;
  412.     WriteString("(Use keyboard to remove me)"); WriteLn; WriteLn;
  413.     p;
  414.     (*just ignore the deactivate event for the
  415.     window to be removed, and all subsequent deactivate, activate events
  416.     for the windows below*)
  417.     REPEAT
  418.       gotAnEvent:= GetNextEvent((*. everyEvent .*)keyDownMask+autoKeyMask,theEvent);
  419.     UNTIL gotAnEvent AND
  420.       ((theEvent.what = mouseDown) OR (theEvent.what = keyDown)
  421.         OR (theEvent.what = autoKey));
  422.     HideWindow(ptr);
  423.     DisposeWindow(ptr);
  424.     (*. REPEAT UNTIL NOT GetNextEvent(activateEvt,theEvent); .*)
  425.     DMQuickDraw.SetPort(savePort);
  426.   END MessageWindow;
  427.  
  428.   PROCEDURE StartReportOnFile(fileName, msg:  ARRAY OF CHAR); 
  429.   BEGIN
  430.     IF NOT repFOpen THEN
  431.       FileSystem.Lookup(repF,fileName,TRUE);
  432.       repFOpen := repF.res = FileSystem.done;
  433.       WriteString("Report started ");
  434.       WriteString(msg);
  435.       WriteString(" calling DMDebugHelp.StartReportOnFile ");
  436.       DocuDateAndTime;
  437.       WriteLn; WriteLn;
  438.     END(*IF*);
  439.   END StartReportOnFile;
  440.   
  441.   PROCEDURE CloseReportFile(msg: ARRAY OF CHAR);
  442.   BEGIN
  443.     IF repFOpen THEN
  444.       WriteString("Report ended ");
  445.       WriteString(msg);
  446.       WriteString(" calling DMDebugHelp.CloseReportFile ");
  447.       DocuDateAndTime;
  448.       WriteLn; WriteLn;
  449.       FileSystem.Close(repF);
  450.       repFOpen := FALSE;
  451.     END(*IF*);
  452.   END CloseReportFile;
  453.  
  454.  
  455.  
  456.  
  457.   PROCEDURE WriteDataStructure(VAR x: ARRAY OF BYTE;
  458.                                  isInForeGround: BOOLEAN; dummy: LONGINT;
  459.                                  msg: ARRAY OF CHAR);
  460.     VAR 
  461.       theEvent: POINTER TO EventRecord; oldIsInForeGround: BOOLEAN;
  462.     PROCEDURE WriteMsg(message: LONGINT);
  463.     BEGIN
  464.       WriteString("  message = ");
  465.       WriteInt(message,0); 
  466.     END WriteMsg;
  467.     PROCEDURE WriteWhere(where: Point);
  468.     BEGIN
  469.       WriteString(" / where = ");
  470.       WriteInt(where.h,0); 
  471.       WriteString(" (h), ");
  472.       WriteInt(where.v,0); 
  473.       WriteString(" (v)");
  474.     END WriteWhere;
  475.     PROCEDURE WriteModif(modifwrd: CARDINAL);
  476.       CONST (* Inside Mac I-252 *) mouseButUp = 7;
  477.         cmdPressed = 8; shiftPressed = 9;  capsLocked = 10; optPressed = 11; 
  478.         ctrlPressed = 12;
  479.       VAR m: BITSET; listStarted: BOOLEAN;
  480.       PROCEDURE AddToList(s: ARRAY OF CHAR);
  481.       BEGIN
  482.         IF listStarted THEN WriteString(", ") END(*IF*);
  483.         WriteString(s);
  484.         listStarted := TRUE;
  485.       END AddToList;
  486.     BEGIN
  487.       WriteString(" /  modifwrd = ");
  488.       m := VAL(BITSET,modifwrd);
  489.       listStarted := FALSE;
  490.       IF cmdPressed IN m THEN AddToList("Cmd") END;
  491.       IF optPressed IN m THEN AddToList("Opt") END;
  492.       IF shiftPressed IN m THEN AddToList("Shift") END;
  493.       IF capsLocked IN m THEN AddToList("CapsLock") END;
  494.       IF ctrlPressed IN m THEN AddToList("Ctrl") END;
  495.       IF NOT (mouseButUp IN m) THEN AddToList("Mousy") END;
  496.       m := m - {mouseButUp, cmdPressed, shiftPressed, capsLocked, optPressed, ctrlPressed};
  497.       IF m <> {} THEN 
  498.         WriteString(" /  modifwrd = ");
  499.         WriteInt(modifwrd,0);
  500.       END(*IF*);
  501.     END WriteModif;
  502.     PROCEDURE WriteHighLevEvent;
  503.     BEGIN
  504.       WriteString("   eventClass = '"); WriteString(theEvent^.eventClass); Write("'");
  505.       WriteString(" / eventID = '"); WriteString(theEvent^.eventID); Write("'");
  506.       WriteString(" / msgVal = "); WriteInt(theEvent^.msgVal,0);
  507.     END WriteHighLevEvent;
  508.     PROCEDURE DoOsEvt(message: LONGINT);
  509.       VAR msg : RECORD CASE : BOOLEAN OF TRUE: m: LONGINT; | FALSE: b1,b2,b3,b4: CHAR (*hi,lo*) END END; 
  510.       (* flag «Accept suspend events» in SIZE resource of shell must be set on to 
  511.       properly maintain isInForeGround.  See Inside Mac VI 5-15. *)
  512.     BEGIN
  513.       msg.m := message; 
  514.       isInForeGround := ODD(ORD(msg.b1)) AND ODD(ORD(msg.b4)); (* Inside Mac VI 5-20 *)
  515.     END DoOsEvt;
  516.   BEGIN (*WriteDataStructure*)
  517.     WriteString(msg);
  518.     theEvent := ADR(x);
  519.     IF theEvent^.what = osEvt THEN
  520.       oldIsInForeGround := isInForeGround;
  521.       DoOsEvt(theEvent^.message);
  522.     END(*IF*);
  523.     WriteString(":  isInForeGround = ");
  524.     IF isInForeGround THEN 
  525.       WriteString("TRUE")
  526.     ELSE
  527.       WriteString("FALSE")
  528.     END; 
  529.     WITH theEvent^ DO
  530.       WriteString("  theEvent.when = "); 
  531.       WriteInt(when,0); 
  532.       WriteLn;
  533.       WriteString("  theEvent.what = "); 
  534.       WriteInt(what,0); 
  535.       CASE what OF
  536.         mouseDown   : 
  537.           WriteString(" (mouseDown)");
  538.           WriteMsg(message);
  539.           WriteWhere(where);
  540.       | mouseUp   :
  541.           WriteString(" (mouseUp)");
  542.           WriteMsg(message);
  543.           WriteWhere(where);
  544.       | keyDown   : 
  545.           WriteString(" (keyDown)");
  546.           WriteString("  msgchar[3] = '");
  547.           Write(msgchar[3]); Write("'");
  548.           WriteString(" [ORD(msgchar[2]) = ");
  549.           WriteInt(ORD(msgchar[2]),0); Write("]");
  550.           WriteModif(modifwrd);
  551.       | updateEvt   : 
  552.           WriteString(" (updateEvt)");
  553.           WriteMsg(message);
  554.       | activateEvt   :
  555.             IF activeFlag IN modifiers THEN
  556.             WriteString(" (activateEvt)");
  557.           ELSE
  558.             WriteString(" (deactivateEvt)");
  559.           END(*IF*);
  560.           WriteMsg(message);
  561.       | kHighLevelEvent   : 
  562.           WriteString(" (kHighLevelEvent)");
  563.           WriteHighLevEvent;
  564.       | osEvt   : 
  565.           WriteString(" (osEvt)");
  566.           IF oldIsInForeGround<>isInForeGround THEN
  567.             IF oldIsInForeGround THEN
  568.               WriteString("From foreground =•=> background");
  569.             ELSE
  570.               WriteString("From background =•=> foreground");
  571.             END(*IF*);
  572.           ELSE
  573.             WriteMsg(message);
  574.           END(*IF*);
  575.       ELSE
  576.           WriteString(" (other)");
  577.           WriteMsg(message);
  578.           WriteWhere(where);
  579.       END(*CASE*);
  580.       WriteLn;
  581.       WriteLn;
  582.     END(*WITH*);
  583.   END WriteDataStructure;
  584.  
  585.  
  586.  
  587.  
  588.   PROCEDURE GetModuleIdent(moduleID: INTEGER; VAR modId: ARRAY OF CHAR);
  589.   
  590.   (*
  591.      ATTENTION!!! The following const. must be the same as those exported by DMBase
  592.   *)
  593.   
  594.   CONST maxKernelMod =    15; (* must be consistent with const declarations below *)
  595.         maxOptMod     =    16; (* must be consistent with const declarations below *)
  596.         doImmediately =  0;
  597.         noBody        =  0;
  598.  
  599.         (* Dialog Machine Kernel *)
  600.  
  601.         (* modules without body *)
  602.         dmPathBase       =  noBody;
  603.         dmLinkLoader  =  noBody;
  604.         dmMemTypes       =  noBody;
  605.         dmDebugHelp      =  noBody;
  606.         dmSys7Events  =  noBody;
  607.                 
  608.         (* modules with body, but otherwise very special *)
  609.         dmQuickDraw      =  0; (* has actually a body, but must be initialized before DMBase *)
  610.         dmLevels       =  0; (* has a body which can be initialized anytime, and should be initialized
  611.                                before all other modules except DMQuickDraw and DMBase *)
  612.         dmHeapWatch      =  0; (* has a body, which requires DMLevels, but since imported by DMStorage
  613.                                will be initialized automatically very early *)
  614.         dmStorage      =  0; (* has a body which must be initialized right after DMLevels, 
  615.                                and must be initialized before all other modules (except 
  616.                                DMQuickDraw) *)
  617.         dmBase          =  0; (* has a body which must be initialized after DMQuickDraw and 
  618.                                can be initialized before all others, even DMLevels, and
  619.                                DMStorage, however it imports from them *)        
  620.         
  621.         dmStrings      =  1;
  622.         dmWindowBase  =  2;
  623.         dmDlgBase      =  3;
  624.         dmConversions =  4;
  625.         dmHandlers    =  5;
  626.         dmMasterBase  =  6;
  627.         dmMenuBase    =  7;
  628.         dmLanguage      =  8;
  629.         dmSystem      =     9;
  630.         dmMessages      = 10;
  631.         dmWindows      = 11;
  632.         dmWindowIO    = 12;
  633.         dmMaster      =    13;
  634.         dmMenus       =    14;
  635.         dmWindIO      = 15;
  636.  
  637.  
  638.         (* optional modules: 
  639.         
  640.            • the body must not be initialized before the kernel (= maxKernelMod +  x).  There initialization 
  641.              Initialization routines are kept and executed only after the 
  642.              kernel is ready and in the sequenceof the constants given 
  643.              below.               
  644.  
  645.            • without body ( = noBody)
  646.            
  647.            • body requires no precondition and can be initialized
  648.              immediately (= doImmediately)
  649.         *) 
  650.  
  651.         
  652.         dmMathLib       = noBody;  (*. no longer part of the kernel .*)
  653.         dmMathLib20     = noBody;
  654.         dmTxtResBase    = noBody;     
  655.         dmClock            = noBody;
  656.         dmQuestions        = noBody;
  657.         dmResBase        = noBody;
  658.         dmPrintBase     = noBody;
  659.         dmHFSBase        = noBody;
  660.         dmWPicIOBase    = noBody;
  661.         
  662.         dmFileNames        = doImmediately;
  663.         dmWTextIOBase    = doImmediately;
  664.         dmPTFiles        = doImmediately;
  665.  
  666.         dmFiles            = maxKernelMod +  1;
  667.         dmErrorMsgs        = maxKernelMod +  2;
  668.         dmDlgErrors        = maxKernelMod +  3;
  669.         dmAlerts        = maxKernelMod +  4;
  670.         dmEntryForms    = maxKernelMod +  5;
  671.         dmEFBase        = maxKernelMod +  6;
  672.         dmEditFields    = maxKernelMod +  7;
  673.         dmTextFields    = maxKernelMod +  8;
  674.         dmResources        = maxKernelMod +  9;
  675.         dmClipboard        = maxKernelMod + 10;
  676.         dmWPictIO        = maxKernelMod + 11;
  677.         dmWTextIO        = maxKernelMod + 12;
  678.         dmPrinting        = maxKernelMod + 13;
  679.         dmOpSys            = maxKernelMod + 14;
  680.         dmSANEEnv       = maxKernelMod + 15;
  681.         dm2DGraphs        = maxKernelMod + 16;
  682.     VAR i: INTEGER;
  683.   BEGIN (* GetModuleIdent *)
  684.     i := 0;
  685.     CASE moduleID OF
  686.     | noBody: CopyString('noBody or doImmediately',0,modId,i);
  687.     | dmStrings   : CopyString('DMStrings',0,modId,i);
  688.     | dmWindowBase   : CopyString('DMWindowBase',0,modId,i);
  689.     | dmDlgBase   : CopyString('DMDlgBase',0,modId,i);
  690.     | dmConversions   : CopyString('DMConversions',0,modId,i);
  691.     | dmHandlers   : CopyString('DMHandlers',0,modId,i);
  692.     | dmMasterBase   : CopyString('DMMasterBase',0,modId,i);
  693.     | dmMenuBase   : CopyString('DMMenuBase',0,modId,i);
  694.     | dmLanguage   : CopyString('DMLanguage',0,modId,i);
  695.     | dmSystem   : CopyString('DMSystem',0,modId,i);
  696.     | dmMessages   : CopyString('DMMessages',0,modId,i);
  697.     | dmWindows   : CopyString('DMWindows',0,modId,i);
  698.     | dmWindowIO   : CopyString('DMWindowIO',0,modId,i);
  699.     | dmMaster   : CopyString('DMMaster',0,modId,i);
  700.     | dmMenus   : CopyString('DMMenus',0,modId,i);
  701.     | dmWindIO   : CopyString('DMWindIO',0,modId,i);
  702.     | dmFiles   : CopyString('DMFiles',0,modId,i);
  703.     | dmDlgErrors   : CopyString('DMDlgErrors',0,modId,i);
  704.     | dmAlerts   : CopyString('DMAlerts',0,modId,i);
  705.     | dmEntryForms   : CopyString('DMEntryForms',0,modId,i);
  706.     | dmEFBase   : CopyString('DMEFBase',0,modId,i);
  707.     | dmEditFields   : CopyString('DMEditFields',0,modId,i);
  708.     | dmTextFields   : CopyString('DMTextFields',0,modId,i);
  709.     | dmResources   : CopyString('DMResources',0,modId,i);
  710.     | dmClipboard   : CopyString('DMClipboard',0,modId,i);
  711.     | dmWPictIO   : CopyString('DMWPictIO',0,modId,i);
  712.     | dmWTextIO   : CopyString('DMWTextIO',0,modId,i);
  713.     | dmPrinting   : CopyString('DMPrinting',0,modId,i);
  714.     | dmOpSys   : CopyString('DMOpSys',0,modId,i);
  715.     | dmSANEEnv   : CopyString('DMSANEEnv',0,modId,i);
  716.     | dm2DGraphs   : CopyString('DM2DGraphs',0,modId,i);
  717.     ELSE 
  718.       CopyString('unknown',0,modId,i);
  719.     END(*CASE*);
  720.     i := 0; CopyString(modId,0,lastModuleID,i);
  721.   END GetModuleIdent;
  722.  
  723.  
  724.   PROCEDURE Message(s1,s2: ARRAY OF CHAR);
  725.   BEGIN
  726.     (*. FileUtil.Message(s1,s2); .*)
  727.   END Message;
  728.   
  729.  
  730. BEGIN
  731.   PutMessageToBack;
  732.   repFOpen := FALSE;
  733.   lastModuleID[0] := 0C;
  734. END DMDebugHelp .
  735.